﻿using System.Collections.Generic;
using DatabaseManager.Core.Models;

namespace DatabaseManager.Core.Interfaces
{
    /// <summary>
    /// 提供面向 WinForm UI 的核心业务逻辑服务，封装了底层 Repository 和 Provider。
    /// </summary>
    public interface IDatabaseService
    {
        #region 数据库注册管理

        void RegisterDatabase(RegisteredDatabase database);
        List<RegisteredDatabase> GetAllDatabases();
        RegisteredDatabase GetDatabaseById(int id);
        void DeleteDatabase(int id);
        bool TestConnection(RegisteredDatabase database);

        #endregion

        #region 元数据读取

        List<TableInfo> GetTables(RegisteredDatabase database);
        List<ColumnInfo> GetColumns(RegisteredDatabase database, string tableName);
        List<IndexInfo> GetIndexes(RegisteredDatabase database, string tableName);
        List<ConstraintInfo> GetConstraints(RegisteredDatabase database, string tableName);

        #endregion

        #region 应用系统管理

        void AddApplication(ApplicationSystem application);
        List<ApplicationSystem> GetAllApplications();
        ApplicationSystem GetApplicationById(int id);
        void UpdateApplication(ApplicationSystem application);
        void DeleteApplication(int id);

        #endregion

        #region 多对多关系管理

        void MapApplicationToDatabase(int applicationId, int databaseId);
        List<ApplicationSystem> GetApplicationsByDatabaseId(int databaseId);
        List<RegisteredDatabase> GetDatabasesByApplicationId(int applicationId);

        #endregion
    }
}